<?php

namespace api\slide\controller;

class AdminIndexController extends \Aaa\slide\controller\AdminIndexController {

    public $baseField = [
        [
            'field' => 'id',
            'name' => 'ID',
        ],
        [
            'field' => 'slide_id',
            'name' => '分组',
            'type' => 'select',
            'options' => [
                ['name' => '无', 'value' => 0],
            ],
            'optionsSource' => [
                'table' => 'slide',
                'nameField' => 'name',
                'valueField' => 'id',
            ],
        ],
        [
            'field' => 'image',
            'name' => '图片',
            'type' => 'image',
        ],
        [
            'field' => 'article_id',
            'name' => '绑定文章',
            'type' => 'select',
            'options' => [
                ['name' => '无', 'value' => 0],
            ],
            'optionsSource' => [
                'table' => 'article',
                'nameField' => 'title',
                'valueField' => 'id',
            ],
        ],
    ];

    public function beforeIndex() {
        $this->actionField = ['id', 'slide_id', 'image', 'article_id'];
        $this->searchField = [
            'common' => [
                'id' => 'accurate',
                'slide_id' => 'accurate',
            ],
        ];
    }

    public function beforeAdd() {
        $this->actionField = ['slide_id', 'image', 'article_id'];
    }

    public function beforeEdit() {
        $this->actionField = ['slide_id', 'image', 'article_id'];
    }

}
